﻿using Fishing.Abstractions;
using Fishing.Common;
using Microsoft.Extensions.DependencyInjection;
using System;
using Fishing.View;

namespace Fishing.ViewModel
{
    public class TaskbarIconViewModel : ObservableObject
    {
        private readonly IProgramController _programController;

        public TaskbarIconViewModel()
        {
            _programController = App.Services.GetRequiredService<IProgramController>();
        }

        private Command _exhaleOrHideCommand;
        public Command ExhaleOrHideOrHideCommand
        {
            get
            {
                if (_exhaleOrHideCommand is null)
                {
                    _exhaleOrHideCommand = new Command(
                        parms => Toogle());
                }

                return _exhaleOrHideCommand;
            }
        }

        private Command _startUpdateCommand;
        public Command StartUpdateCommand
        {
            get
            {
                if (_startUpdateCommand is null)
                {
                    _startUpdateCommand = new Command(
                        parms => StartUpdate());
                }

                return _startUpdateCommand;
            }
        }

        private Command _doubleClickCommand;
        public Command DoubleClickCommand
        {
            get
            {
                if (_doubleClickCommand is null)
                {
                    _doubleClickCommand = new Command(
                        parms => DoubleClick());
                }

                return _doubleClickCommand;
            }
        }

        private Command _exitCommand;
        public Command ExitCommand
        {
            get
            {
                if (_exitCommand is null)
                {
                    _exitCommand = new Command(
                        parms => Exit());
                }

                return _exitCommand;
            }
        }

        private void Toogle()
        {
            _programController.Toggle();
        }

        private void StartUpdate()
        {
            App.Services.GetRequiredService<MainWindow>().QuickUpdateCommand.Execute(null);
        }

        private void DoubleClick()
        {
            _programController.Toggle();
        }

        private void Exit()
        {
            _programController.Exit();
        }
    }
}
